﻿using System.Collections.Generic;
using System.Linq;

namespace Missbot.AIModule.Pet.PetAgainst
{
    public partial class PetAgainstEngine
    {
        [PetGamingEffect(Name = "撕咬")]
        public string 撕咬(Dictionary<string, object> data)
        {
            return DoDemage(SelfPet, AimPet, DemageType.物理, (int)data["Hurt"], "撕咬");
        }

        [PetGamingEffect(Name = "爪击")]
        public string 爪击(Dictionary<string, object> data)
        {
            var msg = DoDemage(SelfPet, AimPet, DemageType.物理, (int)data["Hurt"], "爪击");
            if (AimPet.Buffs.All(b => b.Trigger != CheckTrigger.PhyDefenceFix))
            {
                return msg;
            }

            AimPet.Buffs.RemoveAll(p => p.Trigger == CheckTrigger.PhyDefenceFix);
            msg += $"\n已移除{AimPet.Name}的所有物理防御！";
            return msg;
        }

        [PetGamingEffect(Name = "魔法飞弹")]
        public string 魔法飞弹(Dictionary<string, object> data)
        {
            return DoDemage(SelfPet, AimPet, DemageType.魔法, (int)data["Hurt"], "魔法飞弹");
        }

        [PetGamingEffect(Name = "魔法反制")]
        public string 魔法反制(Dictionary<string, object> data)
        {
            SelfPet.Buffs.Add(new GamingBuff
            {
                Name = "百分比防御",
                Data = new Dictionary<string, object>
                {
                    { "Defence", data["Defence"] }
                },
                RemainTurn = (int)data["Turn"],
                Trigger = CheckTrigger.MagicDefenceFix
            });

            return $"魔法防御增加{data["Defence"]}%，持续{data["Turn"]}个回合(魔法反制)";
        }

        [PetGamingEffect(Name = "反击")]
        public string 反击(Dictionary<string, object> data)
        {
            SelfPet.Buffs.Add(new GamingBuff
            {
                Name = "反击Buff",
                Data = new Dictionary<string, object>
                {
                    { "Hurt", data["Hurt"] }
                },
                RemainTurn = (int)data["Turn"],
                Trigger = CheckTrigger.PhyDefenceFix
            });

            return $"受到物理伤害时，反弹{data["Hurt"]}点魔法伤害，持续{data["Turn"]}个回合";
        }

        [PetGamingEffect(Name = "闷棍")]
        public string 闷棍(Dictionary<string, object> data)
        {
            var msg = DoDemage(SelfPet, AimPet, DemageType.物理, (int)data["Hurt"], "闷棍");
            AimPet.Buffs.Add(new GamingBuff
            {
                Name = "闷棍",
                Data = new Dictionary<string, object>
                {
                    { "Rate", data["Rate"] }
                },
                RemainTurn = (int)data["Turn"] + 1,
                Trigger = CheckTrigger.DoSkill
            });

            return $"{msg}\n对手技能失败率增加{data["Rate"]}%，持续{data["Turn"]}回合";
        }

        [PetGamingEffect(Name = "盾墙")]
        public string 盾墙(Dictionary<string, object> data)
        {
            SelfPet.Buffs.Add(new GamingBuff
            {
                Name = "百分比防御",
                Data = new Dictionary<string, object>
                {
                    { "Defence", data["Defence"] }
                },
                RemainTurn = (int)data["Turn"],
                Trigger = CheckTrigger.PhyDefenceFix
            });

            return $"物理防御增加{data["Defence"]}%，持续{data["Turn"]}个回合(盾墙)";
        }

        [PetGamingEffect(Name = "法术共鸣")]
        public string 法术共鸣(Dictionary<string, object> data)
        {
            SelfPet.Buffs.Add(new GamingBuff
            {
                Name = "百分比伤害",
                Data = new Dictionary<string, object>
                {
                    { "Rate", data["Rate"] }
                },
                RemainTurn = (int)data["Turn"] + 1,
                Trigger = CheckTrigger.MagicAttackFix
            });

            return $"魔法伤害增加{data["Rate"]}%，持续{data["Turn"]}个回合(法术共鸣)";
        }

        [PetGamingEffect(Name = "烈焰喷泉")]
        public string 烈焰喷泉(Dictionary<string, object> data)
        {
            var msg = DoDemage(SelfPet, AimPet, DemageType.魔法, (int)data["Magic"], "烈焰喷泉");
            if (AimPet.Buffs.Any(buff => buff.Trigger == CheckTrigger.MagicDefenceFix))
            {
                msg += $"\n{DoDemage(SelfPet, AimPet, DemageType.物理, (int)data["Phy"], "烈焰喷泉")}";
            }

            return msg;
        }

        [PetGamingEffect(Name = "涂毒")]
        public string 涂毒(Dictionary<string, object> data)
        {
            AimPet.Buffs.Add(new GamingBuff
            {
                Name = "中毒",
                Data = new Dictionary<string, object>
                {
                    { "Hurt", (int)data["Hurt"] }
                },
                RemainTurn = (int)data["Turn"] + 1
            });

            var msg = $"对方已进入中毒状态！每回合受到{(int)data["Hurt"]}点毒系伤害，持续{(int)data["Turn"]}回合";
            return msg;
        }

        [PetGamingEffect(Name = "圣光洗礼")]
        public string 圣光洗礼(Dictionary<string, object> data)
        {
            SelfPet.Buffs.Clear();
            SelfPet.Buffs.Add(new GamingBuff
            {
                Name = "物理攻击增加",
                Data = new Dictionary<string, object>
                {
                    { "addPhy", (int)data["Phy"] }
                },
                RemainTurn = (int)data["Turn"],
                Trigger = CheckTrigger.PhyAttackFix
            });

            var msg = $"自身所有buff已清除！物理攻击增加{(int)data["Phy"]}，持续{(int)data["Turn"]}回合";
            return msg;
        }

        [PetGamingEffect(Name = "穿刺打击")]
        public string 穿刺打击(Dictionary<string, object> data)
        {
            return DoDemage(SelfPet, AimPet, DemageType.真实, (int)data["Hurt"], "穿刺打击");
        }
    }
}